/*
 * @Copyright: EasyCompany 2021
 * @Author: asterisk
 * @Date: 2021-03-15 16:09:43
 * @Description: 
 */

import 'package:flutter/material.dart';

import '../easy_log.dart';

class EasyLoggerConfig {
  final String logName;
  final EasyLogLevel logLevel;
  final Map<String, EasyLogFormatter> formatters = {};
  final Set<EasyLogAppender> appenders = {};
  EasyLoggerConfig({@required this.logName, this.logLevel = EasyLogLevel.ALL});
  void addAppender(EasyLogAppender appender) {
    appenders.add(appender);
  }

  void delAppender(EasyLogAppender appender) {
    appenders.remove(appender);
  }

  void addFormatter(EasyLogFormatter formatter) {
    formatters[formatter.runtimeType.toString()] = formatter;
  }

  void delFormatter(EasyLogFormatter formatter) {
    formatters.remove(formatter.runtimeType.toString());
  }

  Future initAppender(EasyLogParams params) async {
    appenders.forEach((appender) async {
      await appender.init();
    });
  }

  Future unInitAppender() async {
    appenders.forEach((appender) async {
      await appender.unInit();
    });
  }
}
